﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.RestrictedUsage.CSharp.Core;
using Microsoft.RestrictedUsage.CSharp.Semantics;

namespace CSharpParser.CSharpModel
{

    public class DisconnectedSourceLocation : IEquatable<DisconnectedSourceLocation>
    {
        // Fields
        private readonly FileName fileName;
        private readonly Position position;

        // Methods
        public DisconnectedSourceLocation(SourceLocation location)
        {
            this.fileName = location.FileName;
            this.position = location.Position;
        }

        public DisconnectedSourceLocation(FileName fileName, Position position)
        {
            this.fileName = fileName;
            this.position = position;
        }

        public static int Compare(DisconnectedSourceLocation loc1, DisconnectedSourceLocation loc2)
        {
            if (loc1 == null)
            {
                if (loc2 == null)
                {
                    return 0;
                }
                return -1;
            }
            if (loc2 == null)
            {
                return 1;
            }
            int num = loc1.FileName.Value.CompareTo(loc2.FileName.Value);
            if (num == 0)
            {
                num = Position.Compare(loc1.Position, loc2.Position);
            }
            return num;
        }

        public bool Equals(DisconnectedSourceLocation other)
        {
            return (Compare(this, other) == 0);
        }

        public override bool Equals(object obj)
        {
            return this.Equals(obj as DisconnectedSourceLocation);
        }

        public override int GetHashCode()
        {
            return (this.FileName.GetHashCode() + this.Position.GetHashCode());
        }

        // Properties
        public FileName FileName
        {
            get
            {
                return this.fileName;
            }
        }

        public Position Position
        {
            get
            {
                return this.position;
            }
        }
    }



}
